


	
public class MisilEnemigo extends Misil {
	
	
	
	public MisilEnemigo(String [] X,String [] Y,String [] Z)
	{ 	super(X,Y,Z);
		this.CalculaIniciales();
		this.CalculaVelocidad();
		this.setIdMisil("1");
		
	}
	
	
	
	public void CalculaIniciales() //A, B y C son los lugares del array donde arranca el misil.a, b y c son los puntos de la circunsferencia.
	{
	 double r=Math.random()*10;
	 int b=((int) ((Math.random()*100)-50));
	 if(r>5){
		 this.setB((b*1000)+50000);
		 }
	 else{b=-b;
	 	  this.setB((b*1000)+50000);}
	 
	 double r2=Math.random()*10;
	 int a=((int) (Math.sqrt((50*50)-(b*b))));
	 if(r2>5){
		 this.setA(50000+(a*1000));
	 }
	 else{a=-a;
	 	  this.setA((a*1000)+50000);}

	 this.setC((int) (Math.random()*3000+2000));
	 
	 System.out.println("x: "+ a*1000+ " y: "+ b*1000+" z: "+this.getC());
	 
	 
	}
	
	public void CalculaVelocidad ()
	{
		 this.setV((int) ((Math.random()*40)+80));
		 this.setVz((int) ((Math.random()*10)+1));
		 
		 int u=(this.getV()*this.getV())-(this.getVz()*this.getVz());
		 double ran= Math.random()*1;
		 this.setVy((int) (ran*this.getV()));
		 this.setVx((int) (Math.sqrt(u-(this.getVy()*this.getVy()))));
		 
		 if(this.getA()<0){
			 if(this.getVx()>0){}
			 else{this.setVx(-this.getVx());}}
		 ///////////////////////////////CHEQUEAR LO DE ARRIBA //////////////
		 else{
			 if(this.getVx()<0){}
			 else{this.setVx(-this.getVx());}}
		 if(this.getB()<0){
			 if(this.getVy()>0){}
			 else{this.setVy(-this.getVy());}}
		 else{
			 if(this.getVy()<0){}
			 else{this.setVy(-this.getVy());}
		 }
		 System.out.println("vx= "+this.getVx()+" vy= "+this.getVy()+" vz= "+this.getVz()+" vel= "+this.getV());
	}
	
	
	public void run()
	{	boolean aux=true;
		while(aux==true)
		{
			aux= this.ActualizaPosicion();
			
		}
	}
}